local skel = fk.CreateSkill{
  name = "lb__yaogun",
}

Fk:loadTranslationTable{
  ["lb__yaogun"] = "摇滚",
  [":lb__yaogun"] = "当你造成伤害后，你可以令目标回满体力值，然后其进行其体力值数次【闪电】判定直到判定成功（至多三次），且此判定过程中全场非锁定技失效。",
  
  ["@@lb__yaogun-phase"] = "摇滚",
  ["#lb__yaogun"] = "摇滚：你可以令 %dest 回满体力值，然后其进行其体力值数次【闪电】判定直到判定成功（至多三次），此判定过程中全场非锁定技失效",

  ["$lb__yaogun1"] = "不管是反抗，摇摆，沉沦……",
  ["$lb__yaogun2"] = "准备好释放自己了么？",
  ["$lb__yaogun3"] = "这首歌，送给你的~",
}

skel:addEffect(fk.Damage, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name,true) and not data.to.dead
  end,
  on_cost = function (self, event, target, player, data)
    return ((data.card and data.card.skillName == "lb__anke") or  --强致发动
    (player:hasSkill(skel.name) and player.room:askToSkillInvoke(player,{
      skill_name = skel.name,
      prompt = "#lb__yaogun::"..data.to.id,
    }))
  )
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player,"lb__anke",0)
    room:recover({
      who = data.to,
      num = data.to.maxHp - data.to.hp,
      skillName = skel.name,
      recoverBy = player
    })
    for i = 1,data.to.hp, 1 do
      if data.to.dead or i > 3 then
        break
      end
      local pattern = ".|2~9|spade"
      local judge = {
        who = data.to,
        reason = "lightning",
        pattern = pattern,
      }
      for _, t in ipairs(room:getAlivePlayers()) do
        room:addPlayerMark(t,"@@lb__yaogun-phase")
        room:addPlayerMark(t, MarkEnum.UncompulsoryInvalidity.."-phase")
      end
      room:judge(judge)
      for _, t in ipairs(room:getAlivePlayers()) do
        room:removePlayerMark(t,"@@lb__yaogun-phase")
        room:removePlayerMark(t, MarkEnum.UncompulsoryInvalidity.."-phase")
      end
      if judge:matchPattern() then
        room:damage{
          to = data.to,
          damage = 3,
          damageType = fk.ThunderDamage,
          skillName = "lb__yaogun",
        }
        break
      end
    end
  end,
})

return skel